﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoShopping.Model;

namespace GoShopping.BLL.Orders
{
    public class ReturnCashRecordsBean
    {
        public IList<ReturnCashRecords> GetAll()
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnCashRecords).ToList<ReturnCashRecords>();
        }

        public ReturnCashRecords GetOne(int invoiceID)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnCashRecords).Where(
                GoShoppingOrderNBear.ReturnCashRecords.ID == invoiceID).ToSingleObject<ReturnCashRecords>();
        }

        public ReturnCashRecords GetByOrderCode(int orderCode)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnCashRecords).Where(
                GoShoppingOrderNBear.ReturnCashRecords.OrderID == orderCode).ToSingleObject<ReturnCashRecords>();
        }

        public int Insert(ReturnCashRecords invoice)
        {
            return Databases.DBGoShoppingOrder.Insert(
                GoShoppingOrderNBear.ReturnCashRecords).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.MoneyType, invoice.MoneyType).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.OrderID, invoice.OrderID).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.RecordPerson, invoice.RecordPerson).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.Remark, invoice.Remark).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.ReturnCashAccount, invoice.ReturnCashAccount).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.ReturnCashBank, invoice.ReturnCashBank).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.ReturnCashType, invoice.ReturnCashType).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.ReturnDate, invoice.ReturnDate).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.Returner, invoice.Returner).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.Status, invoice.Status).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.TotalPrice, invoice.TotalPrice).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.UserAddress, invoice.UserAddress).AddColumn(
                GoShoppingOrderNBear.ReturnCashRecords.UserName, invoice.UserName).ExecuteReturnAutoIncrementID(
                GoShoppingOrderNBear.ReturnCashRecords.ID);
        }
    }
}
